//
//  FLMOrderDetailController.m
//  FLMSuperS
//
//  Created by xiaoyang on 16/9/15.
//  Copyright © 2016年 FaLaoMiaoNetworkTechnologyCo. All rights reserved.
//

#import "FLMOrderDetailController.h"
#import "FLMManageOrderDetailCell.h"
@interface FLMOrderDetailController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,strong) UITableView *tableView;
@end

@implementation FLMOrderDetailController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self layoutUI];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)layoutUI
{
    if (!_tableView) {
        _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, ScreenW, ScreenH) style:UITableViewStyleGrouped];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.tableFooterView = [UIView new];
        [_tableView registerClass:[FLMManageOrderDetailCell class] forCellReuseIdentifier:@"FLMManageOrderDetailCell"];
        [self.view addSubview:_tableView];
    }
    
}

#pragma mark --UITableViewDelegate && UITableViewDataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 7;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    FLMManageOrderDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:@"FLMManageOrderDetailCell"];
    switch (indexPath.row) {
        case 0:
            [cell configCellWithTitle:@"订单号" subTitle:nil content:@"12345678" contentTextColor:gray contentAlig:NSTextAlignmentLeft];
            break;
        case 1:
             [cell configCellWithTitle:@"商品名" subTitle:nil content:@"10元啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦了" contentTextColor:gray contentAlig:NSTextAlignmentLeft];
            break;
        case 2:
             [cell configCellWithTitle:@"订单类型" subTitle:nil content:@"淘宝" contentTextColor:gray contentAlig:NSTextAlignmentRight];
            break;
        case 3:
             [cell configCellWithTitle:@"商品价格" subTitle:nil content:@"10元" contentTextColor:Red contentAlig:NSTextAlignmentRight];
            break;
        case 4:
            [cell configCellWithTitle:@"商品数" subTitle:nil content:@"1" contentTextColor:Red contentAlig:NSTextAlignmentRight] ;
            break;
        case 5:
            [cell configCellWithTitle:@"订单状态" subTitle:@"*订单状态每日0:00更新" content:@"10元" contentTextColor:Red contentAlig:NSTextAlignmentRight];
            break;
        case 6:
            [cell configCellWithTitle:@"实际返利" subTitle:nil content:@"10元" contentTextColor:gray contentAlig:NSTextAlignmentRight];
            break;
            }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 48;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 110;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *headView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenW, 110)];
    
    UIView *headBg = [[UIView alloc]init];
    headBg.backgroundColor = [UIColor whiteColor];
    [headView addSubview:headBg];
    [headBg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.equalTo(@0);
        make.bottom.equalTo(@-15);
    }];
    
    UILabel *payLb = [[UILabel alloc]init];
    payLb.font = font14;
    payLb.textColor = Red;
    payLb.textAlignment = NSTextAlignmentCenter;
    [headView addSubview:payLb];
    [payLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@30);
        make.left.right.equalTo(@0);
    }];
    NSMutableAttributedString *attString = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"订单支付金额：%@",@"¥5"]];
    [attString addAttribute:NSForegroundColorAttributeName value:black range:NSMakeRange(0, 7)];
    payLb.attributedText = attString;
    
    UILabel *willBackLb = [[UILabel alloc]init];
    willBackLb.textColor = Red;
    willBackLb.textAlignment = NSTextAlignmentCenter;
    willBackLb.font = font14;
    [headView addSubview:willBackLb];
    [willBackLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(payLb.mas_bottom).offset(15);
        make.left.right.equalTo(@0);
    }];
    willBackLb.text = @"就基督教的基督教";
    return headView;
}

@end
